package com.platform.data.service.impl;

import java.util.List;
import java.util.Arrays;

import com.platform.data.domain.EqAlarm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.platform.data.mapper.RuleAlarmMapper;
import com.platform.data.domain.RuleAlarm;
import com.platform.data.service.IRuleAlarmService;
import com.platform.common.core.text.Convert;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

/**
 * 设备告警规则Service业务层处理
 * 
 * @author wangqi
 * @date 2020-08-17
 */
@Service
public class RuleAlarmServiceImpl extends ServiceImpl<RuleAlarmMapper,RuleAlarm> implements IRuleAlarmService
{
    @Autowired
    private RuleAlarmMapper ruleAlarmMapper;

    /**
     * 查询设备告警规则列表
     * 
     * @param ruleAlarm 设备告警规则
     * @return 设备告警规则
     */
    @Override
    public List<RuleAlarm> selectRuleAlarmList(RuleAlarm ruleAlarm)
    {
        return ruleAlarmMapper.selectRuleAlarmList(ruleAlarm);
    }

    /**
     * 设备告警规则
     *
     * @param id 设备告警规则Id
     * @return 设备告警规则
     */
    @Override
    public RuleAlarm selectalarmlimits(String id){
        RuleAlarm ruleAlarm = ruleAlarmMapper.selectalarmlimits(id);
        return ruleAlarm;
    }


    /**
     * 新增设备告警规则
     * 
     * @param ruleAlarm 设备告警规则
     * @return 结果
     */
    @Override
    @Transactional
    public int insertRuleAlarm(RuleAlarm ruleAlarm)
    {
        return ruleAlarmMapper.insert(ruleAlarm);
    }

    /**
     * 修改设备告警规则
     * 
     * @param ruleAlarm 设备告警规则
     * @return 结果
     */
    @Override
    @Transactional
    public int updateRuleAlarm(RuleAlarm ruleAlarm)
    {
        return ruleAlarmMapper.updateById(ruleAlarm);
    }

    /**
     * 删除设备告警规则对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    @Transactional
    public int deleteRuleAlarmByIds(String ids)
    {
        return ruleAlarmMapper.deleteBatchIds(Arrays.asList(Convert.toStrArray(ids)));
    }

    /**
     * 删除设备告警规则信息
     * 
     * @param id 设备告警规则ID
     * @return 结果
     */
    @Override
    @Transactional
    public int deleteRuleAlarmById(Long id)
    {
        return ruleAlarmMapper.deleteById(id);
    }
}
